package blogData.dao.impl;

import account.entity.AccountVO;
import blogData.dao.BlogDataDao;
import blogData.entity.BlogDataVO;
import generic.dao.impl.GenericDaoImpl;

import java.util.List;

public class BlogDataDaoImpl extends GenericDaoImpl<BlogDataVO,Integer> implements BlogDataDao {

    @Override
    public BlogDataVO findByBlogDataId(Integer blogDataId) {
        Object[] params={blogDataId};
        List list=this.findObj("from BlogDataVO a where a.blogDataId=?",params);
        if(list.size() == 0){
            return null;
        }else {
            return (BlogDataVO) list.get(0);
        }
    }

    @Override
    public BlogDataVO updateBlogDataVO(BlogDataVO blogDataVO) {
        this.update(blogDataVO);
        return blogDataVO;
    }

    @Override
    public BlogDataVO findBlogDataVOById(Integer userDataId) {
         return (BlogDataVO)this.findById(BlogDataVO.class,userDataId);

    }

    @Override
    public BlogDataVO addBlogDataVO(BlogDataVO blogDataVO,AccountVO accountVO) {
        accountVO.setBlogDataVO(blogDataVO);
        blogDataVO.setAccountVO(accountVO);
        this.save(blogDataVO);
        return blogDataVO;
    }
}
